package istar.behaviour;

import jade.core.AID;
import jade.lang.acl.ACLMessage;
import jade.lang.acl.MessageTemplate;
import jade.lang.acl.MessageTemplate.MatchExpression;

import java.util.Iterator;

public class TopicMatchExpression implements MatchExpression {
	
	String topic;
	int performative;
	
	TopicMatchExpression(String _topic, int _performative){
		this.topic= _topic;
		this.performative = _performative;
	}
	
	public boolean match(ACLMessage msg){
		String msgTopic = msg.getUserDefinedParameter("topic");
		int msgPerformative = msg.getPerformative();
		boolean out = false;
		if(topic.equals(msgTopic) && performative==msgPerformative)
			out = true;
		return out;
	}
}